package com.shell.arouter

import android.content.Context
import androidx.multidex.MultiDex
import com.durian.app.Durian
import com.durian.app.DurianApplication
import com.durian.base.update.XUpdate
import com.durian.base.update.XUpdate.setHttpRequest
import com.durian.base.update.XUpdate.setUpdateChecker
import com.durian.base.update.XUpdate.setUpdateInstaller
import com.durian.base.utils.CrashHandler
import com.facebook.soloader.SoLoader
import com.henanjianye.soon.communityo2o2.BuildConfig
import com.shell.arouter.demo.HomeAction
import com.shell.arouter.demo.arouter.ActionARouter
import com.shell.arouter.demo.download.ActionDownload
import com.shell.arouter.demo.layoutmanager.ActionLayoutManager
import com.shell.arouter.demo.litho.ActionLitho
import com.shell.arouter.demo.mdc.ActionMdc
import com.shell.arouter.demo.motion.ActionMotion
import com.shell.arouter.demo.multitype.ActionMultiType
import com.shell.arouter.demo.pageing.ActionPageing
import com.shell.arouter.demo.paint.ActionPaint
import com.shell.arouter.demo.permission.ActionPermission
import com.shell.arouter.demo.room.ActionRoom
import com.shell.arouter.demo.view.ActionView
import com.shell.arouter.demo.viewpage2.ActionViewPage2
import com.shell.arouter.demo.xlog.ActionXLog
import com.shell.arouter.update.ReaderUpdateChecker
import com.shell.arouter.update.ReaderUpdateHttpRequest
import com.shell.arouter.update.ReaderUpdateInstaller

/**
 * 说明：RouterApp
 * <p/>
 * 作者：fanly
 * <p/>
 * 类型：Class
 * <p/>
 * 时间：2019-12-19 16:14
 * <p/>
 * 版本：version 1.0
 */
class RouterApp : DurianApplication(){
    override fun isDebug(): Boolean {
        return BuildConfig.DEBUG
    }

    override fun attachBaseContext(base: Context?) {
        super.attachBaseContext(base)
        MultiDex.install(base)
    }

    override fun initApplication() {
        SoLoader.init(this,false)
        CrashHandler(this).init()
        Durian.init(this,false)
        initUpdate()
    }

    private fun initUpdate() {
        setHttpRequest(ReaderUpdateHttpRequest())
            .setUpdateChecker(ReaderUpdateChecker())
            .setUpdateInstaller(ReaderUpdateInstaller())
    }

}


val homeActionList = mutableListOf<HomeAction>().apply {
    add(HomeAction(ActionARouter::class.java))
    add(HomeAction(ActionPermission::class.java))
    add(HomeAction(ActionMultiType::class.java))
    add(HomeAction(ActionXLog::class.java))
    add(HomeAction(ActionRoom::class.java))
    add(HomeAction(ActionMdc::class.java))
    add(HomeAction(ActionMotion::class.java))
    add(HomeAction(ActionLitho::class.java))
    add(HomeAction(ActionViewPage2::class.java))
    add(HomeAction(ActionPageing::class.java))
    add(HomeAction(ActionView::class.java))
    add(HomeAction(ActionLayoutManager::class.java))
    add(HomeAction(ActionPaint::class.java))
    add(HomeAction(ActionDownload::class.java))
}